﻿Public Class frmXemChiTietTinNha 
    Public _dangtinDTO As New DangTinDTO
    Public _chunhaDTO As New ChuNhaDTO
    Public tableLoaiNha As New DataTable
    Public tableDiaChi As New DataTable
    Public tableKhuVuc As New DataTable
    Private Sub frmXemChiTietTinNha_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Dim diachiDTO As New DiaChiDTO
        Dim diachiBUS As New DiaChiBUS
        '----------------------------------------------------------------------------------------------------
        Dim loaiNhaDTO As New LoaiNhaDTO
        Dim loaiNhaBUS As New LoaiNhaBUS
        '----------------------------------------------------------------------------------------------------
        Dim kvDTO As New KhuVucDTO
        Dim kvBUS As New KhuVucBUS
        '----------------------------------------------------------------------------------------------------
        tableLoaiNha = loaiNhaBUS.GetAll()
        tableKhuVuc = kvBUS.GetAll()
        tableDiaChi = diachiBUS.GetAll()
        '------------------------------------------------------------------------------------------
        For i As Integer = 0 To tableDiaChi.Rows.Count - 1
            If Convert.ToInt32(tableDiaChi.Rows(i)("MaDiaChi").ToString()) = _dangtinDTO.MaDiaChi Then
                diachiDTO.MaDiaChi = Convert.ToInt32(tableDiaChi.Rows(i)("MaDiaChi").ToString())
                diachiDTO.Duong = tableDiaChi.Rows(i)("Duong").ToString()
                diachiDTO.Phuong = tableDiaChi.Rows(i)("Phuong").ToString()
                diachiDTO.Quan = tableDiaChi.Rows(i)("Quan").ToString()
                diachiDTO.SoNha = tableDiaChi.Rows(i)("SoNha").ToString()
                Exit For
            End If
        Next
        '------------------------------------------------------------------------------------------
        For i As Integer = 0 To tableLoaiNha.Rows.Count - 1
            If Convert.ToInt32(tableLoaiNha.Rows(i)("MaLoaiNha").ToString()) = _dangtinDTO.MaLoaiNha Then
                lbLoaiNha.Text = tableLoaiNha.Rows(i)("TenLoaiNha")
                Exit For
            End If
        Next
        '----------------------------------------------------------------------------------------------------
        lbSucChua.Text = _dangtinDTO.SucChua.ToString() + " (người)"
        lbDienTich.Text = _dangtinDTO.DienTich.ToString() + " (m2)"
        lbTieuDe.Text = _dangtinDTO.TieuDe.ToString()
        lbDiaChi.Text = diachiDTO.SoNha.ToString() + ", " + diachiDTO.Duong.ToString() + ", " + diachiDTO.Phuong.ToString() + ", " + diachiDTO.Quan.ToString()
        lbGiaThue.Text = _dangtinDTO.GiaThue.ToString() + " (VNĐ)"
        lbHoTen.Text = _chunhaDTO.HoTen
        lbSDT.Text = _chunhaDTO.DienThoai
        lbEmail.Text=_chunhaDTO.Email
        '----------------------------------------------------------------------------------------------------
        If _dangtinDTO.ChoNamThue = 1 Then
            ckChoNamThue.Checked = True
        Else
            ckChoNamThue.Checked = False
        End If

        If _dangtinDTO.ChoNuThue = 1 Then
            ckChoNuThue.Checked = True
        Else
            ckChoNuThue.Checked = False
        End If

        If _dangtinDTO.ChoNauAn = 1 Then
            ckNauAn.Checked = True
        Else
            ckNauAn.Checked = False
        End If

        If _dangtinDTO.OChungChu = 1 Then
            ckChungChu.Checked = True
        Else
            ckChungChu.Checked = False
        End If

        If _dangtinDTO.OGhep = 1 Then
            ckOGhep.Checked = True
        Else
            ckOGhep.Checked = False
        End If

        If _dangtinDTO.Internet = 1 Then
            ckInternet.Checked = True
        Else
            ckInternet.Checked = False
        End If

        If _dangtinDTO.TruyenHinhCap = 1 Then
            ckTruyenHinhCap.Checked = True
        Else
            ckTruyenHinhCap.Checked = False
        End If

        If _dangtinDTO.GanTramXeBuyt = 1 Then
            ckXeBuyt.Checked = True
        Else
            ckXeBuyt.Checked = False
        End If
    End Sub

    Private Sub SimpleButton2_Click(sender As System.Object, e As System.EventArgs) Handles SimpleButton2.Click
        Me.Close()
    End Sub
End Class